<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<!-- 引入样式 -->
		<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
		<script src="/js/vue.js"></script>
		<script src="https://unpkg.com/element-ui/lib/index.js"></script>
		<script src="/js/jquery-3.1.1.min.js"></script>
		<script src="/js/myhttp.js"></script>
		<style>
		.login-one{
		  background-image:url(../image/login1.jpg);
		  background-size: cover;
		  background-repeat:no-repeat;
		  overflow:hidden;
		  height: 100%;
		}
		
	
		</style>
	</head>
	<body class="login-one">
		<div id="app">
			<!-- 用户登录 -->
				<el-form  class="demo-ruleForm" label-width="80px" style="background-color: white;width: 500px;position: fixed;left:35%;top:30%;border-radius: 10px;">
					 <h1 align="center">马牌damn蛋糕销售商城</h1>
					<div  v-if="!loginbycodes" >
						<el-form-item label="用户名" prop="userName" >
							<el-col :span="22">
								<el-input v-model="username"></el-input>
							</el-col>
						</el-form-item>
						<el-form-item label="密码" prop="userPwd">
							<el-col :span="22">
								<el-input show-password v-model="userpwd"></el-input>
							</el-col>
						</el-form-item>
					</div>

					<el-form-item >
							<el-button icon="el-icon-user-solid" type="success" size="mini" @click="login">登录</el-button>
					</el-form-item>
				</el-form>
		</div>
		
	</body>
	
	<script>
		if (localStorage.getItem("uid")==""){
			localStorage.setItem("uid","")
		}
		new Vue({
				 el:"#app",
				data:{
					username:"",
					userpwd:"",
					loginbycodes:false,
					email:"",
					code:""
				},
				methods:{
					 login(){
						let that=this
						 myhttps("/User/Login",
								 {
									 "loginaccount":that.username,
									 "loginpassword":that.userpwd
								 }
						 ).then(res=>{
							 localStorage.setItem("uid",res.body.uid)
							 window.location.replace('./index.html')
						 }).catch(res=>{
							 that.$message.error("error!"+res.msg)
						 })

					 }
				}
	
				 
			})
	
	</script>
</html>
